<?php

namespace App\Admin\Controllers;

use App\Models\PersonalUser;
use App\Models\Resume;
use App\Models\ResumeSend;
use App\Models\User;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use Illuminate\Support\Facades\Request;

class UserController extends AdminController
{
    protected $title = '用户列表';

    protected function grid()
    {
        $grid = new Grid(new User());

        $grid->column('uid', __('Id号'));
        $grid->column('nickname', __('昵称'));
        $grid->column('mobile', __('手机号码'));
        $grid->column('wxInfo.nickname', __('微信昵称'));
        $grid->column('wxInfo.headimg', '微信头像')->image(self::$baseImg, 100, 100);

        $grid->column('created_at', __('创建时间'));
        $grid->column('updated_at', __('更新时间'));

        $grid->disableCreateButton();
        $grid->disableFilter();
        $grid->disableExport();
        $grid->disableRowSelector();
        $grid->disableColumnSelector();

        $grid->actions(function ($actions) {
            // 去掉删除
            $actions->disableDelete();

        });

        return $grid;
    }

    protected function detail($id)
    {
        $show = new Show(User::findOrFail($id));

        $show->field('nickname', __('昵称'));
        $show->field('mobile', __('手机号码'));


        $show->panel()
            ->tools(function ($tools) {
                $tools->disableDelete();
            });

        return $show;
    }

    protected function form()
    {
        $form = new Form(new User());

        $form->text('nickname', '昵称');
        $form->text('mobile', '手机号码');

        $form->tools(function (Form\Tools $tools) {
            // 去掉`删除`按钮
            $tools->disableDelete();
        });

        $form->footer(function ($footer) {
            // 去掉`继续编辑`checkbox
            $footer->disableEditingCheck();

            // 去掉`继续创建`checkbox
            $footer->disableCreatingCheck();
        });

        return $form;
    }

}